package cn.com.self.apis.escrow.service.impl;

import cn.com.self.apis.escrow.entity.EscrowAmountChange;
import cn.com.self.apis.escrow.mapper.EscrowAmountChangeMapper;
import cn.com.self.apis.escrow.service.IEscrowAmountChangeService;
import cn.com.self.apis.util.CopyUtils;
import cn.com.selfsoft.smartcity.core.service.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class EscrowAmountChangeImpl extends BaseServiceImpl<EscrowAmountChange, String> implements IEscrowAmountChangeService {

    @Autowired
    private EscrowAmountChangeMapper escrowAmountChangeMapper;

    @Override
    public EscrowAmountChange createAmountChange(EscrowAmountChange entity) {
        entity.setCreateTime(new Date());
        entity.setUpdateTime(new Date());
        entity.setChangeState(1);
        return this.create(entity);
    }

    @Override
    public EscrowAmountChange loadAmountChangeInfoById(String id) {
        EscrowAmountChange result = escrowAmountChangeMapper.loadAmountChangeInfoById(id);
        return result;
    }

    @Override
    public EscrowAmountChange updateAmountChange(String id, EscrowAmountChange entity) {
        EscrowAmountChange escrowAmountChange = this.load(id);
        CopyUtils.copyProperties(entity, escrowAmountChange);
        escrowAmountChange.setUpdateTime(new Date());
        EscrowAmountChange update = this.update(escrowAmountChange);
        return update;
    }


}
